//
//  Emoticon.swift
//  02-表情
//
//  Created by 张宏芝 on 15/9/11.
//  Copyright © 2015年 kama. All rights reserved.
//

import UIKit

// 表情符号模型
class Emoticon: NSObject {

/// 表情文字
    var chs:String?
/// 表情图片
    var png:String?
//    图像的完整路径
    var imagePath:String{
        return (png != nil) ? NSBundle.mainBundle().bundlePath + "/Emoticons.bundle/" + png! :""
    }
/// emoji编码
    var code:String?{
        didSet{
//            读取十六进制的字符串
            let scanner = NSScanner(string: code!)
            var value: UInt32 = 0
            scanner.scanHexInt(&value)
            
            emoji = String(Character(UnicodeScalar(value)))
        }
    }
//    emoji字符串
    var emoji:String?
    
//  删除按钮标记
    var isRemove = false
    
//    表情的使用频率
    var times = 0
    
//    空白按钮
    var isEmpty = false
    init(isEmpty:Bool) {
        super.init()
        self.isEmpty = isEmpty
    }
    init(isRemove:Bool) {
        super.init()
        self.isRemove = isRemove
    }
    
    init(dict:[String:String]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) { }
    
    override var description:String{
        let keys = ["chs","png","code","isRemove","isEmpty","times"]
        return dictionaryWithValuesForKeys(keys).description
    }
}














